Skip to content

fix(weather): use nearest openmeteo hourly data#4123

Merged
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:openmeteo
Apr 28, 2026
Merged

fix(weather): use nearest openmeteo hourly data#4123
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:openmeteo

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented Apr 28, 2026

Open-Meteo updates current_weather every 15 minutes, but the hourly array only has entries at full hours. The old code did an exact timestamp match - so at 14:15, 14:30 or 14:45 it never found a match and silently fell back to index 0, showing midnight values for humidity, feels-like temp, precipitation, etc.

Fix: findLastIndex((hour) => hour.time <= currentMs) - the last hourly entry at or before the current time.

While fixing the bug I found several dead branches left over from the #4032 refactor: a path for pre-transposed hourly data that #parseWeatherApiResponse makes unreachable, an Array.isArray guard that's always true, and a Log.debug inside the dead branch. Removing those accounts for most of the ~40 deleted lines - the actual fix is one line.

Fixes #4122.

Open-Meteo updates current_weather every 15 min, but hourly data
exists only on full hours. Exact timestamp matching could miss and
fall back to index 0, causing midnight values in current weather.

Pick the last hourly entry at or before current_weather.time,
remove dead hourly-shape fallback code, and simplify mapping.

Update tests to guard against index-0 fallback and add hourly-type
coverage with frozen time.

Fixes MagicMirrorOrg#4122
@khassel khassel merged commit 8af3d02 into MagicMirrorOrg:develop Apr 28, 2026
12 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the openmeteo branch April 28, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants